package model;

import java.util.HashMap;

public class TraitementThreadDonneVie implements Runnable {

	private static HashMap<Coordonnee, Cellule> mapTps2 = null;
	private static HashMap<Coordonnee, Integer> mapDonneVie = null;
	private static Object[] coord;
	private int debut = 0;
	private int fin = 0;

	public TraitementThreadDonneVie(HashMap<Coordonnee, Cellule> mapTps2,
			HashMap<Coordonnee, Integer> mapDonneVie, 
			Object [] coords,
			int debut, int fin) {
		TraitementThreadDonneVie.mapTps2 = mapTps2;
		TraitementThreadDonneVie.mapDonneVie = mapDonneVie;
		TraitementThreadDonneVie.coord = coords;
		this.debut = debut;
		this.fin = fin;
	}

	synchronized static void ajouteCellule(HashMap<Coordonnee, Cellule> map,
			Coordonnee coord, Cellule cel) {
		mapTps2.put(coord, cel);
	}

	public void run() {
		for (int x = debut; x <= fin; x++) {
			Integer i = mapDonneVie.get(coord[x]);
			if (i != null) {
				if (i.intValue() == 3) {
					Cellule cel = new Cellule((Coordonnee) coord[x]);
					ajouteCellule(mapTps2, (Coordonnee) coord[x], cel);

				}
			}
		}
	}
}
